//
//  AddViewController.m
//  09_Work 通讯录
//
//  Created by dllo on 16/7/25.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "AddViewController.h"
#import "LabelView.h"

@interface AddViewController ()
@property (nonatomic, strong) UITextField *nameTextField;
@property (nonatomic, strong) UITextField *ageTextField;
@property (nonatomic, strong) UITextField *sexTextField;
@property (nonatomic, strong) UITextField *phoneTextField;

@property (nonatomic, strong) NSMutableDictionary *dic;

@end

@implementation AddViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    UIView *view = [LabelView createNameLabelFrame:CGRectMake(80, 100, 60, 30) nameLabelText:@"姓名" ageLabelFrame:CGRectMake(80, 160, 60, 30) ageLabelText:@"年龄" sexLabelFrame:CGRectMake(80, 210, 60, 30) sexLabelText:@"性别" phoneLabelFrame:CGRectMake(80, 260, 60, 30) phoneLabelText:@"电话"];
    [self.view addSubview:view];
    
    self.nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 100, 150, 30)];
    self.nameTextField.layer.borderWidth = 1;
    [self.view addSubview:self.nameTextField];

    self.ageTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 160, 150, 30)];
    self.ageTextField.layer.borderWidth = 1;
    [self.view addSubview:self.ageTextField];
    
    self.sexTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 210, 150, 30)];
    self.sexTextField.layer.borderWidth = 1;
    [self.view addSubview:self.sexTextField];
    
    self.phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(160, 260, 150, 30)];
    self.phoneTextField.layer.borderWidth = 1;
    [self.view addSubview:self.phoneTextField];
    
    UIButton *addButton = [UIButton buttonWithType:UIButtonTypeSystem];
    addButton.frame = CGRectMake(100, 320, 60, 30);
    [addButton setTitle:@"添加" forState:UIControlStateNormal];
    [self.view addSubview:addButton];
    [addButton addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)click:(UIButton *)button {
//    self.dic = [NSMutableDictionary dictionary];
    self.dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:self.nameTextField.text, @"name", self.ageTextField.text, @"age", self.sexTextField.text, @"gender", self.phoneTextField.text, @"phoneNumber", nil];
    [self.delegate passDic:self.dic];
    [self.navigationController popToRootViewControllerAnimated:YES];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
